<?php 
$weeknames = array('日','一','二','三','四','五','六');
?>
<ul>
	<li>
 		<span>开始时间:</span>
 		<div id = 'price-view'>
 			<p class="time" style = 'overflow: hidden;'>
                <?php $i=0; foreach ($TicketShowings as $show):?>
                	<?php $show = $show['TicketShowing']?>
                	<?php if($show['showtime']>date('Y-m-d')):$i++?>
					<a href = 'javascript:;' 
						data-id = '<?php echo $show['id']?>' 
						data-class = 'pg-<?php echo $show['id']?>' <?php echo ($i==1)?'class="goumai"':''?>>
                    	<?php echo date(str_replace('w', $weeknames [date('w', strtotime($show['showtime']))], 'Y年m月d日 周w H:i'),strtotime($show['showtime']))?>
					</a>
					<?php endif;?>
				<?php endforeach;?>
				<?php if($i == 0){ echo '<span>'.date('Y-m-d').' 无可购票品</span>';} ?>
			</p>
			<?php if($i>8):?>
			<a href="javascript:;" id = 'more_price_date' class="moreYc">更多演出场次</a>
			<style>#price-view .time{height: <?php echo ($i>4)?'90':'45'?>px;}</style>
			<?php endif;?>
		</div>
    </li>
    <li id = 'price-hole'>
		<span>选择价格:</span>
		<?php $price = array();?>
		<?php $j=0;
            if($i == 0){ 
				echo '<span>无可选演出</span>';
            }else{
			foreach ($price as $tk => $tv):?>
			<p class = 'thp pg-<?php echo md5($tk)?>' <?php echo ($j++>0)?'style=display:none':''; ?>>
				<?php foreach ($tv as $p):?>
					<?php if($p['ticket_price_state_id'] == 1):	//正常?>
					<a href="javascript:;"  data-eticket ='<?php echo $p['spt_eticket'];?>' data-eprice='<?php echo $p['eprice'];?>' data-price='<?php echo $p['price'];?>' onclick = 'CART.selPrice(<?php echo $p['id']?>,this)'><?php echo $p['price'];echo ($p['description'])?"({$p['description']})":false;?></a>
					<?php elseif($p['ticket_price_state_id'] == 2): //缺票?>
					<a href="javascript:;"  class = 'sold_lack' data-showtime = "<?php echo date(str_replace('w', $weeknames [date('w', strtotime($p['showtime']))], 'Y年m月d日 周w H:i'),strtotime($p['showtime']))?>" title = '票品暂缺,您可以点击登记试试运气' onclick = 'CART.askfor(<?php echo $p['id']?>,this)'><?php echo $p['price'];echo ($p['description'])?"({$p['description']})":false;?></a>
					<?php elseif($p['ticket_price_state_id'] == 3): //卖完?>
					<a href="javascript:;" class = 'sold_out' title = '该门票已经售罄'><?php echo $p['price'];?></a>
					<?php else:?>
					<a href="javascript:;" class = 'sold_stop' title = '该门票已经停售'><?php echo $p['price'];?></a>
					<?php endif;?>
                <?php endforeach;?>
	        </p>	
		  <?php endforeach;
		}
		 ?>
     </li>
    <div class="clear"></div>
    <li id = 'ticket_goumai' class="gmai" style = 'text-align:center'>
    	<?php if($ed < date('Y-m-d')):?>
    		<a href="javascript:;" class="ticket_time_out">票品已下架</a>
    	<?php else:?>
    		<a href="javascript:seat.f.selectTicketShowing();" class="jiaru">在线选座</a>
        <?php endif;?>
    </li>
	<div class="clear"></div>
</ul>
 
	<script>
	$(document).ready(function(){
		  $('#price-view .time a').each(function(){
			$(this).click(function(){
				$('#price-view .time a').removeClass('goumai');
				var pclass = '.'+$(this).addClass('goumai').data('class');
				seat.p.ticketShowing = $(this).data('id');
				  jQuery('#price-hole p').hide();
				  jQuery('#price-hole').find(pclass).show();
				  jQuery('#ticket_goumai .buy_etitcke').hide();
			});
		  });

		  seat.p.ticketShowing = $('#price-view .time a.goumai').data('id');
		  
		  $( '#price-hole a,.buy_etitcke' ).tooltip({
		      position: {
		        my: "center bottom-5",
		        at: "center top",
		      }
		    });
		  $('#more_price_date').toggle(function(){
				var $tar = $(this).prev();
				$tar.animate({height:$tar.get(0).scrollHeight},300)
				$(this).attr('class','lessYc').html('收起');
			},function(){
				$(this).prev().animate({height:'90px'},300)
					.end().attr('class','moreYc').html('更多演出场次');
			})
		});
	seat = {p:{},f:{}};
	seat.p.ticketShowing = false;
	seat.f.selectTicketShowing = function(){
		if(seat.p.ticketShowing){
			location.href = 'seat/SeatSolds/index/'+seat.p.ticketShowing;
		}else{
			zmx.tip('请选择要购买的演出场次',false);
		}
	};
	</script>